package com.eyas.business.controllor.common;

import com.eyas.business.model.jdbcEntity.table.KeyWorldsInfo;
import com.eyas.business.service.TestService;
import com.eyas.business.service.common.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @Auther: 王龙龙
 * @Date: 2019/2/21 14:36
 * @Description:
 */
@Controller
@RequestMapping("/eyas/admin/")
public class CommonAction {
/*    @Autowired
    private TestService testService;*/
    @Autowired
    private CommonService commonService;

    @RequestMapping(value = "/pagegoto/{pagename}",method = RequestMethod.GET)
    public String pageGoTo(@PathVariable(value = "pagename",required = true)String pagename) {
//        testService.test();
        return pagename;
    }

    @RequestMapping(value = "/pagegoto/{dlv1}/{pagename}",method = RequestMethod.GET)
    public String pageGoTo(@PathVariable("dlv1") String dlv1, @PathVariable("pagename")String pagename) {
        return dlv1+"/"+pagename;
    }
    @RequestMapping(value = "/pagegoto/{dlv1}/{dlv2}/{pagename}",method = RequestMethod.GET)
    public String pageGoTo(@PathVariable(value = "dlv1",required = true) String dlv1,
                           @PathVariable(value = "dlv1",required = true) String dlv2,
                           @PathVariable(value = "pagename",required = true)String pagename) {
        return dlv1+"/"+dlv2+"/"+pagename;
    }

    @GetMapping("/dictionary/{dcode}")
    @ResponseBody
    public List<KeyWorldsInfo> dictionary(@PathVariable String dcode) {
        List<KeyWorldsInfo> list = commonService.dictionary(dcode);
        return list;
    }

    @DeleteMapping("/superadmin/{tablename}/{primarykey}/{primaryval}")
    @ResponseBody
    public String deleteInfo(@PathVariable("tablename") String tablename, @PathVariable("primarykey") String primarykey, @PathVariable("primaryval") Integer primaryval, HttpSession session) {
        this.commonService.deleteInfo(tablename,primarykey,primaryval,session);
        return "{\"success\":true}";
    }
}
